{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "752d20f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[ \u001b[32m\"a\"\u001b[39m, \u001b[32m\"b\"\u001b[39m ]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "let v = [[]]\n",
    "\n",
    "v.at(-1)?.push( 'a' )\n",
    "v.at(-1)?.push( 'b' )\n",
    "\n",
    "v.at(-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73c5ec8f",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Stack<T> {\n",
    "  private items: T[] = []\n",
    "\n",
    "  push(item: T): number {\n",
    "    return this.items.push(item)\n",
    "  }\n",
    "\n",
    "  pop(): T | undefined {\n",
    "    return this.items.pop()\n",
    "  }\n",
    "\n",
    "  peek(): T | undefined {\n",
    "    return this.items[this.items.length - 1]\n",
    "  }\n",
    "\n",
    "  elements(): T[] {\n",
    "    return this.items.reverse()\n",
    "  }\n",
    "\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "fcfc0ab9",
   "metadata": {},
   "outputs": [],
   "source": [
    "const _DEBUG = true\n",
    "/**\n",
    " * @param { any[] } args \n",
    " */\n",
    "const _DBG = ( ...args ) => {\n",
    "  if( ! _DEBUG ) return\n",
    "  if( args.length === 0 ) return\n",
    "  if( typeof(args[0]) === 'function' ) {\n",
    "    args[0]()\n",
    "    return\n",
    "  }\n",
    "  console.debug( 'TOPIC: ', ...args )\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "41e9af9b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TOPIC:  OK FROM FUNCTION\n",
      "TOPIC:  OK1 OK2\n"
     ]
    }
   ],
   "source": [
    "_DBG( () => { _DBG( \"OK FROM FUNCTION\") } )\n",
    "_DBG(  \"OK1\", \"OK2\" )"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Deno",
   "language": "typescript",
   "name": "deno"
  },
  "language_info": {
   "codemirror_mode": "typescript",
   "file_extension": ".ts",
   "mimetype": "text/x.typescript",
   "name": "typescript",
   "nbconvert_exporter": "script",
   "pygments_lexer": "typescript",
   "version": "5.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
